<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="../../node_modules/jquery/dist/jquery.js"></script>
    <script>
        // promise like 即能像promise一样进行 await 使用的结构=object|function，且其有then方法=function、

        function isPromiseLike(value) {
            return (
                value != null
                && (typeof value === 'object' || typeof value === 'function')
                && typeof value.then === 'function'
            )
        }

        function p() {
            return new Promise(resolve => {
                resolve()
            })
        }

        console.log(
            isPromiseLike(p())
        );
        console.log(
            isPromiseLike($.ajax())
        );

        $.ajax({
            url: 'http://localhost:7731/',
            type: 'get',
            dataType: 'json',
            success: function (data) { console.log(data) },
        })
    </script>
</body>

</html>